package com.jf.cloud.service.sysmanager.common.taglib;

 

import javax.servlet.http.HttpServletRequest;


/**
 * sk 标签 辅助类
 * @author jspp@qq.com
 */
public class TagsHelper {
	/**
	 * 是否重复刷新 是返回 true    否 false 
	 */
	public static boolean isReFresh(HttpServletRequest request) {
	      boolean returnBoolean = true;
	      String rand_request = "";
	      String rand_varivab="";
	      String rand_varivab_session="";
	      if (request.getParameter("rand_n_") != null) {
	          rand_request = request.getParameter("rand_n_");
	      }else {
			 //-----使用的不是 防刷新 form 无法验证
	    	 return false;
	      }
	      if (request.getParameter("randAttribute_v_") != null) {
	          rand_varivab = request.getParameter("randAttribute_v_");
	      }
	      if(request.getSession().getAttribute(rand_varivab)!=null){
 	          rand_varivab_session = (String)request.getSession(false).getAttribute(rand_varivab);
	      }else{
	          rand_varivab_session = "cym";
	      }
	      if (rand_request.equals(rand_varivab_session)) {
	         returnBoolean = false;	         
             request.getSession().removeAttribute(rand_varivab);
	         
	      }  
	    return returnBoolean;
	  }
	
	/**
	 * 手动获取  limit 字符串 [不涉及业务]
	 * @author ouyang 创建时间：2014-04-17 16:04:38
	 */
	public static String getLimitStr(int pageSize, int pageIndex) {
		if (pageSize <=0) {
			pageSize = 10;
		}
		if (pageIndex <= 1) {
			pageIndex = 1;
		}
	    return " LIMIT "+((pageIndex-1)*pageSize)+","+(pageSize);
	}
	 
}
